<?php
require "../includes/db.php"; 
$mysqli = new MossCMS();
if ($_SESSION[$prefix.'_username'] == ""){  header("Location: ../login.php"); exit;}
if ($_SESSION[$prefix."_security"] < 1){header("location:../login.php?action=5"); exit;}




if ($_SERVER['REQUEST_METHOD'] == "POST") { 

	$username	= $_POST['username'];
	$fullname 	= $_POST['fullname'];
	$level 		= $_POST['level'];
	


		//ADD USER TO DB
		$mysqli->user_add($username, $fullname, $level);		
		
		$mysqli->admin_action($z_user, "Added user $username ");

header("Location:user_list.php");

	
}//END POST

 
$user_level_list = $mysqli->get_user_levels();
?>

<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8" />
<link rel="stylesheet" type="text/css" href="../includes/admin.css"/>
<title><?php echo $global_title;?></title>



</head>
<body>

<div id="wrap">
	<div id="page-header">
		<?php include('includes/header.php');?>

	</div>
	
	<div id="page-body">
		<div id="tabs">
			<?php $tab="main"; include('includes/header_tabs.php');?>
		</div>

		<div id="acp">
		<div class="panel">
			<span class="corners-top"><span></span></span>
				<div id="content">
				<div id="menu">
						
					<?php include('includes/menu_top.php');?>	
					<?php include('includes/menu_main.php');?>
					</div>
	
					<div id="main">
<a name="maincontent"></a>


	<h1>Edit User</h1>


	<form id="form1" name="form1" enctype="multipart/form-data" method="post" action=""  onSubmit="return verify();">

		
	<fieldset><legend>Add User</legend>

		<dl>
            <dt>Username:</dt>
            <dd><input type="text" name="username" id="username" autofocus required></dd>
         </dl>
		<dl>
            <dt>Fullname:</dt>
            <dd><input type="text" name="fullname" id="fullname" size="40" value="<?php echo $userinfo['user_fullname'];?>" /></dd>
         </dl>

         
         <dl>
			<dt>User Level:</dt>
			<dd>
				<select name="level" id="level">
					<?php for($x = 0; $x < sizeof($user_level_list); $x++){ ?>
						<option value="<?php echo $user_level_list[$x][user_level_id];?>" <?php if($user_level_list[$x][user_level_id] == $userinfo['user_level_id']){echo " selected ";}?> > <?php echo $user_level_list[$x][user_level_name];?></option>			
					<?php } ?>
				
				</select>
				
			</dd>
		</dl>
		
	
		
				

<p class="submit-buttons"><input type="submit" class="button1" name="submit" id="submit" value="Add User" /></p>
	</fieldset>
    </form>

    
		</div><!-- main -->
	</div><!-- content -->
<span class="corners-bottom"><span></span></span>
</div><!-- panel -->
</div><!-- acp -->

	
	<div id="page-footer">
	<?php include('includes/footer.php');?>
				</div>
</div><!-- page-body -->
</div><!-- wrap -->


</body> 
</html>